package com.icloud.cer.rest.msg;

import java.io.IOException;

import com.icloud.cer.rest.Constants;

public class MessageHeader extends AbsMsgObject<MessageHeader>{
	public static final int BYTE_COUNT=8;
	private int 	size_;
	//消息类型 command
	private short 	type_;
	
	//'b' or 'l' b是高字节 l是低字节
	private char 	flag_;
		
	public MessageHeader() {
		super( BYTE_COUNT );
		this.flag_ = Constants.DEFAULT_CODEC_FLAG;
	}

	@Override
	protected void doSerialize(DataFilterOutputStream dos) throws IOException {
		dos.writeInt( this.size_ );
		dos.writeShort( this.type_ );
		dos.writeShort(this.flag_ );
	}

	@Override
	protected MessageHeader doDeserialize(BDataFilterInputStream dis) throws IOException {
		this.size_ = dis.readInt();
		this.type_ = dis.readShort();
		this.flag_ = (char)dis.readShort();
		return this;
	}

	public int getSize_() {
		return size_;
	}

	public void setSize_(int size_) {
		this.size_ = size_;
	}

	public short getType_() {
		return type_;
	}

	public void setType_(short type_) {
		this.type_ = type_;
	}


	public char getFlag_() {
		return flag_;
	}

	public void setFlag_(char flag_) {
		this.flag_ = flag_;
	}

}
